package com.im.project.controller;

import com.im.common.result.JsonPage;
import com.im.common.result.JsonResult;
import com.im.project.entity.dto.BaseQueryDto;
import com.im.project.entity.dto.DealContactApplyDto;
import com.im.project.entity.vo.ContactApplyVo;
import com.im.project.service.ContactApplyService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * 申请记录 控制层
 *
 * @author yunZhouJiaDi
 */
@RestController
@RequestMapping("/contactApply")
@Api(tags = "ContactApplyController", description = "申请记录相关接口")
public class ContactApplyController {

    @Resource
    private ContactApplyService contactApplyService;

    @GetMapping("/list")
    @ApiOperation("分页查询添加申请列表")
    public JsonResult<JsonPage<ContactApplyVo>> queryContactApplyList(BaseQueryDto baseQueryDto) {
        return JsonResult.success(JsonPage.restPage(contactApplyService.queryContactApplyList(baseQueryDto)));
    }

    @PostMapping("/deal")
    @ApiOperation("处理申请")
    public JsonResult dealContactApply(@Validated @RequestBody DealContactApplyDto dealContactApplyDto) {
        return JsonResult.success(contactApplyService.dealContactApply(dealContactApplyDto));
    }

    @DeleteMapping("/{id}")
    @ApiOperation("删除好友申请记录")
    public JsonResult deleteContactApply(@PathVariable Long id) {
        return JsonResult.success(contactApplyService.deleteContactApply(id));
    }

}
